const util = require('../../../../utils/util.js')

Component({
    created() {
        if(this.data.shopdetails.attachVo == undefined){
            this.data.shopdetails.attachVo = {}
        }
        if(this.data.shopdetails.brandPhoto  != "" && this.data.shopdetails.attachVo.brandPhoto != null){
            this.data.shopdetails.brandPhoto = util.thumbnail(this.data.shopdetails.brandPhoto, 700, 375)
        }
        if(this.data.shopdetails.attachVo.thedoor != "" && this.data.shopdetails.attachVo.thedoor != null){
            this.data.shopdetails.attachVo.thedoor = util.thumbnail(this.data.shopdetails.attachVo.thedoor, 150, 150)
        }
        if(this.data.shopdetails.attachVo.scene != "" && this.data.shopdetails.attachVo.thedoor != null){
            this.data.shopdetails.attachVo.scene = util.thumbnail(this.data.shopdetails.attachVo.scene, 150, 150)
        }
        if(this.data.shopdetails.shippingConfig != "" && this.data.shopdetails.shippingConfig != null ){
            this.data.shippingConfig = JSON.parse(this.data.shopdetails.shippingConfig)
        }
        this.setData({
            shopdetails:this.data.shopdetails
        })
    },
    properties: {
        shopdetails: {
            type: Object,
            value: {}
        },
    },
    data: {
        shippingConfig:''
    },
    methods: {
        dialNowClick(){
            wx.makePhoneCall({
                phoneNumber: this.data.shopdetails.telephone, //此号码并非真实电话号码，仅用于测试
                success:function(){
                },
                fail:function(){
                    console.log("拨打电话失败！")
                }
            })
        },
        reachDestination(){

                    wx.openLocation({
                        latitude: this.data.shopdetails.shop.lat,
                        longitude: this.data.shopdetails.shop.lng,
                        name: '目的地',
                    })

        }
    }
});
